<?php extract($overallRank); ?>

<div id="content">
    <h2><?php if (count($groupRank) > 5): ?><a href="/student/groups">My Groups</a><?php else: ?>My Groups<?php endif; ?></h2>
    <div class="searchForm">
        <?=form_open('/student/group_search');?>
        <?=form_input('searchTerm');?>
        <?=form_submit('', 'Search');?>
        <?=form_close();?>
    </div>
    <table class="groups">
        <tr><th>Group Name</th><th>Group Type</th><th>My Score</th><th>My Rank</th><th># of Students</th><th>Avg. Points</th></tr>
        <?php if (count($college) > 1): ?><tr>
            <td><a href="/student/group_details/college/<?=$college['college_id'];?>"><?=$college['college_name'];?></a></td>
            <td>College</td>
            <td><?=$user_score;?></td>
            <td><?=$college['rank'];?></td>
            <td><?=$college['count'];?></td>
            <td><?=round($college['average']);?></td>
        </tr><?php endif; ?>
        <?php if (count($school) > 1): ?><tr>
            <td><a href="/student/group_details/school/<?=$school['school_id'];?>"><?=$school['school_name'];?></a></td>
            <td>School</td>
            <td><?=$user_score;?></td>
            <td><?=$school['rank'];?></td>
            <td><?=$school['count'];?></td>
            <td><?=round($school['average']);?></td>
        </tr><?php endif; ?>
        <?php if (count($major) > 1): ?><tr>
            <td><a href="/student/group_details/major/<?=$major['major_id'];?>"><?=$major['major_name'];?></a></td>
            <td>Major</td>
            <td><?=$user_score;?></td>
            <td><?=$major['rank'];?></td>
            <td><?=$major['count'];?></td>
            <td><?=round($major['average']);?></td>
        </tr><?php endif; ?>
        <?php if (count($minor) > 1): ?><tr>
            <td><a href="/student/group_details/minor/<?=$minor['minor_id'];?>"><?=$minor['minor_name'];?></a></td>
            <td>Minor</td>
            <td><?=$user_score;?></td>
            <td><?=$minor['rank'];?></td>
            <td><?=$minor['count'];?></td>
            <td><?=round($minor['average']);?></td>
        </tr><?php endif; ?>
<tr><td class="divider" colspan="6">&nbsp;</td></tr>
        <?php if (isset($groupRank)): ?>
                <?php foreach ($groupRank as $index => $group): ?>
                <?php if ($index == 5) break; ?><tr>
                    <td><a href="/student/group_details/group/<?=$group['group_id'];?>"><?=ucwords($group['group_name']);?></a></td>
                    <td><?=$group['group_type'];?></td>                    
                    <td><?=$group['score'];?></td>
                    <td><?=$group['rank'];?></td>
                    <td><?=$group['count'];?></td>
                    <td><?=round($group['average']);?></td>
                </tr><?php endforeach; ?>
        <?php endif; ?>
    </table>

    <br /><br />
    
    <h2><a href="/student/events">My Events</a></h2>
    <div class="searchForm">
        <?=form_open('/student/event_search');?>
        <?=form_input('searchTerm');?>
        <?=form_submit('', 'Search');?>
        <?=form_close();?>
    </div>
    <table class="events">
        <tr><th>Event Name</th><th>Group Name</th><th>Location</th><th>Event Date</th><th>Time</th></tr>
        <?php if (isset($events['upcoming'])): ?>
            <?php foreach ($events['upcoming'] as $index => $event): ?>
            <?php if ($index == 5) break; ?><tr>
                <td><a href="/student/event_details/<?=$event['event_id'];?>"><?=ucwords($event['event_name']);?></a></td>
                <td><a href="/student/group_details/group/<?=$event['group_id'];?>"><?=ucwords($event['group_name']);?></a></td>
                <td><?=$event['location_name'];?></td>
                <td><?=$event['start_date'];?></td>
                <td><?=$event['start_time'] . ' - ' . $event['end_time'];?></td>
            </tr><?php endforeach; ?>
        <?php endif; ?>
<tr><td class="divider" colspan="5">&nbsp;</td></tr>
        <?php if (isset($events['past'])): ?>
            <?php foreach ($events['past'] as $index => $event): ?>
            <?php if ($index == 5) break; ?><tr>
                <td><a href="/student/event_details/<?=$event['event_id'];?>"><?=ucwords($event['event_name']);?></a></td>
                <td><a href="/student/group_details/group/<?=$event['group_id'];?>"><?=ucwords($event['group_name']);?></a></td>
                <td><?=$event['location_name'];?></td>
                <td><?=$event['start_date'];?></td>
                <td><?=$event['start_time'] . ' - ' . $event['end_time'];?></td>
            </tr><?php endforeach; ?>
        <?php endif; ?>
    </table>

    <br /><br />
    
    <h2><a href="/student/companies">My Companies</a></h2>
    <div class="searchForm">
        <?=form_open('/student/company_search');?>
        <?=form_input('searchTerm');?>
        <?=form_submit('', 'Search');?>
        <?=form_close();?>
    </div>
    <table class="companies">
        <tr><th>Company Name</th><th>Location</th><th>Industry</th></tr>
        <?php if (isset($companies)): ?>
            <?php foreach ($companies as $index => $company): ?>
            <?php if ($index == 5) break; ?><tr>
                <td><a href="/student/company_details/<?=$company['company_id']; ?>"><?=ucwords($company['company_name']);?></a></td>
                <td><?=ucwords($company['city'] . ', ' . $company['state']);?></td>                    
                <td><?=$company['industry'];?></td>
            </tr><?php endforeach; ?>
        <?php endif; ?>
    </table>
</div> <!-- #content -->